//scripts for header
$(function () {
    $(".headerButtons").click(
        function() {
            var button = this;
            $(".headerBlockDirects").each(function(index, item) {
                if (item.id == button.title) $(item).css('display', 'block');
                else $(item).css('display','none');
            })
        }
    );
});

$(function () {
    $("span.login").click(
        function() {
            var block = $("div.login").first();
            if (block.css('display') == 'block') block.css('display', 'none');
            else block.css('display', 'block');
        }
    );
});

function DropDown(el) {
    this.dd = el;
    this.initEvents();
}
DropDown.prototype = {
    initEvents: function () {
        var obj = this;

        obj.dd.on('click', function (event) {
            $(this).toggleClass('active');
            event.stopPropagation();
        });
    }
};

$(function() {
    var dd = new DropDown( $('#dd') );
    $(document).click(function() {
        // all dropdowns
        $('.wrapper-dropdown').removeClass('active');
    });
});

